//
//  TZYMineColletionCell.m
//  Moment
//
//  Created by dllo on 16/1/4.
//  Copyright © 2016年 片刻. All rights reserved.
//

#import "TZYMineColletionCell.h"

@implementation TZYMineColletionCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self createSubView];
    }
    return self;
}



-(void)createSubView
{
    self.type = [[UILabel alloc] init];
    //self.type.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.type];
    
    [self.type mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(@20);
        make.width.mas_equalTo(@150);
        make.height.mas_equalTo(@25);
        
    }];

    
    self.titleLb = [[UILabel alloc] init];
    //self.titleLb.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:self.titleLb];
    
    [self.titleLb mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.type.mas_bottom).offset(10);
        make.right.mas_equalTo(@(-20));
        make.left.mas_equalTo(@20);
        make.height.mas_equalTo(@(SCREEN_HEIGHT / 4 / 3));
        
    }];
    
    
    self.imgView = [[UIImageView alloc] init];
    //self.imgView.backgroundColor = [UIColor purpleColor];
    [self.contentView addSubview:self.imgView];
    
    [self.imgView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLb.mas_bottom).offset(10);
        make.right.mas_equalTo(@(-20));
        make.left.mas_equalTo(@20);
        make.height.mas_equalTo(@(SCREEN_HEIGHT / 4));
        
    }];
    

}


#pragma mark - set
-(void)setMyModel:(TZYHomeData *)myModel{
    if (_myModel != myModel) {
        
        _myModel = myModel;
    }
    
    self.type.text = self.myModel.name;
    self.type.font = [UIFont systemFontOfSize:[TZYFontSize getFontSizeForMiddle]];
    self.titleLb.text = self.myModel.title;
    self.titleLb.font = [UIFont systemFontOfSize:[TZYFontSize getFontSizeForBig]];
    self.titleLb.numberOfLines = 0;
    [self.imgView sd_setImageWithURL:self.myModel.coverimg];
    
//    //重新设置title frame
//    CGFloat titleHeight = [[self class] heightForTitle:self.myModel.title];
//    CGRect tepFrame = self.titleLb.frame;
//    tepFrame.size.height = titleHeight;
//    self.titleLb.frame = tepFrame;
//    
//    self.imgView.frame = CGRectMake(SCREEN_WIDTH/20, SCREEN_WIDTH/20 + self.titleLb.frame.size.height + self.titleLb.frame.origin.y,SCREEN_WIDTH - SCREEN_WIDTH/10, SCREEN_HEIGHT/4);
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
